/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package protocol;

import connection.*;
import java.net.*;
import java.util.*;

public class Protocol {

private Connection connection;

public Protocol(Connection connection){
    this.connection = connection;
}

   public Packet connect(InetSocketAddress receiver){
       return new Packet(connection.getInetSocketAddress(), receiver, MyProtocol.CONNECT, null);
   }

   public Packet ping(){
       Vector v = new Vector<InetSocketAddress>();
       v.add(connection.getInetSocketAddress());
       return new Packet(connection.getInetSocketAddress(),
                         MyProtocol.PING,
                         v);
   }

   public Packet pong(Vector<InetSocketAddress> v, int ttl){
       return new Packet(connection.getInetSocketAddress(), v.elementAt(1), MyProtocol.PONG, v, ttl);
   }

  
}
